
<#assign Parent = (package.Entity?substring(0,(package.Entity)?length-7))>
package ${package.Controller};

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import ${package.Entity}.${entity};
import ${Parent}.service.${table.serviceName};
import lombok.extern.slf4j.Slf4j;
import com.scshyzh.common.core.MochaResponse;
import com.scshyzh.common.core.ResponseCode;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 *
 * ${table.name!}
 *
 * @author ${author}
 * @since ${date}
 */
@Tag(name = "请自定义")
@Slf4j
@RestController
@RequestMapping("<#if table.name??>/${table.name}</#if>")
public class ${table.controllerName} {

    @Autowired
    private ${table.serviceName} ${table.serviceName?uncap_first};

    @Operation(summary = "新增")
    @PostMapping
    public MochaResponse<${entity}> insert(@RequestBody ${entity} entity){
        return MochaResponse.builder().build().response(entity, ResponseCode.Success);
    }

    @Operation(summary = "修改")
    @PutMapping("/{id}")
    public MochaResponse<ResponseCode> update(@PathVariable("id") Long id, @RequestBody ${entity} entity){
        return MochaResponse.responseSuccess();
    }


    @Operation(summary = "分页查询")
    @PostMapping("/page")
    public MochaResponse<List<${entity}>> search(@RequestBody ${entity} search){
        List<${entity}> list = new ArrayList<>();
        return MochaResponse.builder().build().response(list, ResponseCode.Success);
    }

    @Operation(summary = "查询单条")
    @GetMapping("/{id}")
    public MochaResponse<${entity}> get(@PathVariable("id") Long loginCode){
        ${entity} entity = new ${entity}();
        return MochaResponse.builder().build().response(entity, ResponseCode.Success);
    }

    @Operation(summary = "删除")
    @DeleteMapping("/{id}")
    public Object delete(@PathVariable("id") Long id){
        return MochaResponse.responseSuccess();
    }



}
